
#include <gtest\gtest.h>


#include "LevelLoader.h"
#include "Game.h"

//------------------------------------------------------------------
//LEVELLOADER
//------------------------------------------------------------------

//LevelLoader throws a string when an invalid level is passed to the 
//constructor class. 
TEST(LevelLoader, throwsExceptionWhenLoadingFileThatDoesNotExist)
{
	EXPECT_THROW({LevelLoader invalidLevel(123);}, string );
}

//LevelLoaderClass creates an object without any throws when
//A file that corresponds to the given level exists
TEST(LevelLoader, aValidFileIsSucessfullyLoadedByConstructor)
{
	EXPECT_NO_THROW({LevelLoader validLevel(0);});
}

//The known position of digdug is correctly loaded from a file
TEST(LevelLoader, digdugsPositionIsCorrectlyLoadedFromFile)
{
	LevelLoader game_data(0);
	Point digdug_location(24,9);
	EXPECT_TRUE(game_data.getDigdugPosition() == digdug_location);
}

//All Monsters are correcly loaded from a file
TEST(LevelLoader, monstersPositionIsCorrectlyLoadedFromFile)
{	
	LevelLoader game_data(1);		
	vector <Point> loaded_monster_data = game_data.getMonstersPosition();
	vector <Point> expected_monster_data;
	
	expected_monster_data.push_back(Point(9,14));
	expected_monster_data.push_back(Point(39,14));

	EXPECT_TRUE(loaded_monster_data == expected_monster_data);
}

//Map Data is correctly loaded
TEST(LevelLoader, mapDataIsCorrectlyLoadedFromAFile)
{	
	LevelLoader game_data(200);		

	vector<vector<Movable_type>> expected_map;
	for(int x = 0; x < 50; x++)
	{
		expected_map.push_back(vector<Movable_type>());
		for(int y = 0; y < 50; y++)
		{
			if( x !=24 || y !=24)
				expected_map.back().push_back(SAND);
			else
				expected_map.back().push_back(HOLE);
		}
	}

	EXPECT_TRUE(expected_map == game_data.getMapData());
}


//------------------------------------------------------------------
//GAME
//------------------------------------------------------------------

//The action 
//A simple test map is provided
//TEST(Game, updateGivenResultsInExpectedActions)
//{	
//	LevelLoader game_data(200);		
//
//	vector<vector<Movable_type>> expected_map;
//	for(int x = 0; x < 50; x++)
//	{
//		expected_map.push_back(vector<Movable_type>());
//		for(int y = 0; y < 50; y++)
//		{
//			if( x !=24 || y !=24)
//				expected_map.back().push_back(SAND);
//			else
//				expected_map.back().push_back(HOLE);
//		}
//	}
//
//	EXPECT_TRUE(expected_map == game_data.getMapData());
//}
